var _timer = 30000;
var _split = 1;
var _id = 0;
var _status = "资料读取中...";

var g_numcolor = [0,1,1,2,2,3,3,1,1,2,2,3,1,1,2,2,3,3,1,1,2,3,3,1,1,2,2,3,3,1,1,2,3,3,1,1,2,2,3,3,1,2,2,3,3,1,1,2,2,3];
var colors = ["","red", "blue", "green"];

var XH = null;
var XH1= null;
if (window.XMLHttpRequest)
{// code for all new browsers
    XH = new XMLHttpRequest();
    XH1 = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{// code for IE5 and IE6
  XH = new ActiveXObject("Microsoft.XMLHTTP");
  XH1 = new ActiveXObject("Microsoft.XMLHTTP");
} else 
  alert("Your browser does not support XMLHTTP.");

var timer_id;
var bo0_num = 0;
var b13_num = 0;
var mchk0 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
var mchk1 = [0,0,0];
var mchk2 = [0,0,0];
var mchk3 = [0,0,0];
var mchk20 = [0,0,0];
var mchk28 = [0,0,0];
var mchk30 = [0,0,0];
var mchk46 = [0,0,0,0];
var mchk47 = [0,0,0];
//   Math.round(n) = 去小数取整数，Math.floor(n) = 四舍五入到整数

function bo()
{
	if (document.all.bo0.value-0 > 0) {
		document.all.bo0.value = 0-document.all.bo0.value;
	}
	if (document.all.bo0.value-0 <= -1000) {		// bo0_num
		SetCookie("bo0", document.all.bo0.value);
		bo0_num = document.all.bo0.value-0;
		if (timer_id) clearTimeout(timer_id);
		timer();
	} else {
		document.all.bo0.value = bo0_num;
	}
}

function getcontent()
{
    XH.open("POST", "op.php?op=xml&fp=bnow1&id="+_id+"&split="+_split+"&bonum="+bo0_num,false); 
    try{XH.send("");return XH.responseText; }catch(E){}
}

function timer()
{
	window.status = _status;
	var i;
	var str = getcontent();  // 读取下注资料 
	if (str=="") { alert("Error 1"); }
	if (str=="-1") { location.reload(); }
	var a = str.split("\n");
	show_rate0(a[0]);
	show_rate1(a[1]);
	show_rate2(a[2]);
	show_rate3(a[3]);
	show_rate20(a[4]);
	show_rate28(a[5]);
	show_rate30(a[6]);
	show_rate46(a[7]);
	show_rate47(a[8]);
	show_titleAmu(a[9]);
	window.status = "";

	//timer_id = setTimeout("timer()", _timer);
}

function show_rate20(str)
{
	var a0 = str.split(",");
	var win = a0[0];
	for (i=1; i<3; i++) {
		a00 = a0[i].split("@");
		rate = a00[0];
		count = a00[1]-0;
		amount = a00[2]-0;
		chktime = a00[4]-0;
		document.all["rate20_"+i].innerHTML = rate;
		mchk20[i] = Math.floor(amount);
		if (count > 0) {
			document.all["amount20_"+i].innerHTML = "<a href=op.php?op=agent&fp=betlist&dt1="+_open+"&dt2="+_open+"&bettype=20&numbers="+i+">"+Math.floor(amount)+"</a>";
			if (chktime == 0 && amount > 0) {
				document.all["chg20_"+i].innerHTML = "<input type=checkbox id=rrr20_"+d2(i)+" onclick=\"quickrrr(20, "+i+")\">";
			} else {
				document.all["chg20_"+i].innerHTML = "<input disabled type=checkbox id=rrr20_"+d2(i)+">";
			}
		} else {
			document.all["amount20_"+i].innerHTML = Math.floor(amount);
			document.all["chg20_"+i].innerHTML = "<input disabled type=checkbox id=rrr20_"+d2(i)+">";
		}
		win1 = Math.floor(win - a00[3]);
		document.all["win20_"+i].innerHTML = win1;
		document.all["win20_"+i].className = (win1 < 0 ? "lost" : "win");
	}
}

function show_rate28(str)
{
	var a0 = str.split(",");
	var win = a0[0];
	for (i=1; i<3; i++) {
		a00 = a0[i].split("@");
		rate = a00[0];
		count = a00[1]-0;
		amount = a00[2]-0;
		chktime = a00[4]-0;
		document.all["rate28_"+i].innerHTML = rate;
		mchk28[i] = Math.floor(amount);
		if (count > 0) {
			document.all["amount28_"+i].innerHTML = "<a href=op.php?op=agent&fp=betlist&dt1="+_open+"&dt2="+_open+"&bettype=28&numbers="+i+">"+Math.floor(amount)+"</a>";
			if (chktime == 0 && amount > 0) {
				document.all["chg28_"+i].innerHTML = "<input type=checkbox id=rrr28_"+d2(i)+" onclick=\"quickrrr(28, "+i+")\">";
			} else {
				document.all["chg28_"+i].innerHTML = "<input disabled type=checkbox id=rrr28_"+d2(i)+">";
			}
		} else {
			document.all["amount28_"+i].innerHTML = Math.floor(amount);
			document.all["chg28_"+i].innerHTML = "<input disabled type=checkbox id=rrr28_"+d2(i)+">";
		}
		win1 = Math.floor(win - a00[3]);
		document.all["win28_"+i].innerHTML = win1;
		document.all["win28_"+i].className = (win1 < 0 ? "lost" : "win");
	}
}

function show_rate30(str)
{
	var a0 = str.split(",");
	var win = a0[0];
	for (i=1; i<3; i++) {
		a00 = a0[i].split("@");
		rate = a00[0];
		count = a00[1]-0;
		amount = a00[2]-0;
		chktime = a00[4]-0;
		document.all["rate30_"+i].innerHTML = rate;
		mchk30[i] = Math.floor(amount);
		if (count > 0) {
			document.all["amount30_"+i].innerHTML = "<a href=op.php?op=agent&fp=betlist&dt1="+_open+"&dt2="+_open+"&bettype=30&numbers="+i+">"+Math.floor(amount)+"</a>";
			if (chktime == 0 && amount > 0) {
				document.all["chg30_"+i].innerHTML = "<input type=checkbox id=rrr30_"+d2(i)+" onclick=\"quickrrr(30, "+i+")\">";
			} else {
				document.all["chg30_"+i].innerHTML = "<input disabled type=checkbox id=rrr30_"+d2(i)+">";
			}
		} else {
			document.all["amount30_"+i].innerHTML = Math.floor(amount);
			document.all["chg30_"+i].innerHTML = "<input disabled type=checkbox id=rrr30_"+d2(i)+">";
		}
		win1 = Math.floor(win - a00[3]);
		document.all["win30_"+i].innerHTML = win1;
		document.all["win30_"+i].className = (win1 < 0 ? "lost" : "win");
	}
}

function show_rate3(str)
{
	var a0 = str.split(",");
	var win = a0[0];
	for (i=1; i<3; i++) {
		a00 = a0[i].split("@");
		rate = a00[0];
		count = a00[1]-0;
		amount = a00[2]-0;
		chktime = a00[4]-0;
		document.all["rate3_"+i].innerHTML = rate;
		mchk3[i] = Math.floor(amount);
		if (count > 0) {
			document.all["amount3_"+i].innerHTML = "<a href=op.php?op=agent&fp=betlist&dt1="+_open+"&dt2="+_open+"&bettype=3&numbers="+i+">"+Math.floor(amount)+"</a>";
			if (chktime == 0 && amount > 0) {
				document.all["chg3_"+i].innerHTML = "<input type=checkbox id=rrr3_"+d2(i)+" onclick=\"quickrrr(3, "+i+")\">";
			} else {
				document.all["chg3_"+i].innerHTML = "<input disabled type=checkbox id=rrr3_"+d2(i)+">";
			}
		} else {
			document.all["amount3_"+i].innerHTML = Math.floor(amount);
			document.all["chg3_"+i].innerHTML = "<input disabled type=checkbox id=rrr3_"+d2(i)+">";
		}
		win1 = Math.floor(win - a00[3]);
		document.all["win3_"+i].innerHTML = win1;
		document.all["win3_"+i].className = (win1 < 0 ? "lost" : "win");
	}
}

function show_rate2(str)
{
	var a0 = str.split(",");
	var win = a0[0];
	for (i=1; i<3; i++) {
		a00 = a0[i].split("@");
		rate = a00[0];
		count = a00[1]-0;
		amount = a00[2]-0;
		chktime = a00[4]-0;
		document.all["rate2_"+i].innerHTML = rate;
		mchk2[i] = Math.floor(amount);
		if (count > 0) {
			document.all["amount2_"+i].innerHTML = "<a href=op.php?op=agent&fp=betlist&dt1="+_open+"&dt2="+_open+"&bettype=2&numbers="+i+">"+Math.floor(amount)+"</a>";
			if (chktime == 0 && amount > 0) {
				document.all["chg2_"+i].innerHTML = "<input type=checkbox id=rrr2_"+d2(i)+" onclick=\"quickrrr(2, "+i+")\">";
			} else {
				document.all["chg2_"+i].innerHTML = "<input disabled type=checkbox id=rrr2_"+d2(i)+">";
			}
		} else {
			document.all["amount2_"+i].innerHTML = Math.floor(amount);
			document.all["chg2_"+i].innerHTML = "<input disabled type=checkbox id=rrr2_"+d2(i)+">";
		}
		win1 = Math.floor(win - a00[3]);
		document.all["win2_"+i].innerHTML = win1;
		document.all["win2_"+i].className = (win1 < 0 ? "lost" : "win");
	}
}

function show_rate1(str)
{
	var a0 = str.split(",");
	var win = a0[0];
	for (i=1; i<3; i++) {
		a00 = a0[i].split("@");
		rate = a00[0];
		count = a00[1]-0;
		amount = a00[2]-0;
		chktime = a00[4]-0;
		document.all["rate1_"+i].innerHTML = rate;
		mchk1[i] = Math.floor(amount);
		if (count > 0) {
			document.all["amount1_"+i].innerHTML = "<a href=op.php?op=agent&fp=betlist&dt1="+_open+"&dt2="+_open+"&bettype=1&numbers="+i+">"+Math.floor(amount)+"</a>";
			if (chktime == 0 && amount > 0) {
				document.all["chg1_"+i].innerHTML = "<input type=checkbox id=rrr1_"+d2(i)+" onclick=\"quickrrr(1, "+i+")\">";
			} else {
				document.all["chg1_"+i].innerHTML = "<input disabled type=checkbox id=rrr1_"+d2(i)+">";
			}
		} else {
			document.all["amount1_"+i].innerHTML = Math.floor(amount);
			document.all["chg1_"+i].innerHTML = "<input disabled type=checkbox id=rrr1_"+d2(i)+">";
		}
		win1 = Math.floor(win - a00[3]);
		document.all["win1_"+i].innerHTML = win1;
		document.all["win1_"+i].className = (win1 < 0 ? "lost" : "win");
	}
}

function show_rate0(str)
{
	var count0 = 0;
	var amount0 = 0;
	var a0 = str.split(",");
	var a1 = a0[0].split("@");
	var uamount = a1[0]-0;
	var win = a1[1]-0;
	for (i=1; i<50; i++) {
		a00 = a0[i].split("@");
		num = a00[0];
		num2 = (num < 10 ? "0"+num : num);
		rate = a00[1];
		count = a00[2]-0;
		amount = a00[3]-0;
		win1 = Math.floor(win-a00[4]-0);
		chktime = a00[5]-0;
		i2 = 0;
		if (amount > 0) {
			if (bo0_num != 0 && win1 < bo0_num) {
				i2 = bo0_num - win1;
				i2 = parseInt(i2 / (rate-1))-0;
				if (i2 > 5 && i2 < 10) { i2 = 10; }
				if (i2 < 6) { i2 = 0; }
			}
			if (amount-i2 < 0) { i2 = amount; }
		}
		if (amount<=0 && i2>0) {
			i2 = 0;
		}
		document.all["num0_"+i].innerHTML = num2;
		document.all["num0_"+i].className = "td1"+colors[g_numcolor[num]];
		document.all["rate0_"+i].innerHTML = rate;
		mchk0[i] = Math.floor(amount);
		if (count > 0) {
			document.all["amount0_"+i].innerHTML = "<a href=op.php?op=agent&fp=betlist&dt1="+_open+"&dt2="+_open+"&bettype=99&numbers="+num2+">"+Math.floor(amount)+"</a>";
		} else {
			document.all["amount0_"+i].innerHTML = Math.floor(amount);
		}
		if (amount-i2 >= 0 && i2 > 0 && chktime == 0 && amount > 0) {
			document.all["chg0_"+i].innerHTML = "<input type=checkbox id=rrr0_"+d2(i)+" onclick=\"quickrrr0("+i+")\">";
		} else {
			document.all["chg0_"+i].innerHTML = "<input type=checkbox disabled id=rrr0_"+d2(i)+">";
		}
		if (i2 < 5) { i2 = 0; }
		i2 = Math.round(i2);
		if (i2 == 0) { i2 = ""; }
		document.all["win0_"+i].innerHTML = win1;
		document.all["win0_"+i].className = (win1 < 0 ? "lost" : "win");
		document.all["bo_"+i].innerHTML = i2;
		count0+=count;
		amount0+=amount;
	}

	document.all.useamount.innerHTML = (uamount);
	document.all.amount0.innerHTML = Math.floor(amount0);
}

function show_rate46(str)
{
	var a0 = str.split(",");
	var win = a0[0];
	for (i=1; i<4; i++) {
		a00 = a0[i].split("@");
		rate = a00[0];
		count = a00[1]-0;
		amount = a00[2]-0;
		chktime = a00[4]-0;
		document.all["rate46_"+i].innerHTML = rate;
		mchk46[i] = Math.floor(amount);
		if (count > 0) {
			document.all["amount46_"+i].innerHTML = "<a href=op.php?op=agent&fp=betlist&dt1="+_open+"&dt2="+_open+"&bettype=46&numbers="+i+">"+Math.floor(amount)+"</a>";
			if (chktime == 0 && amount > 0) {
				document.all["chg46_"+i].innerHTML = "<input type=checkbox id=rrr46_"+d2(i)+" onclick=\"quickrrr(46, "+i+")\">";
			} else {
				document.all["chg46_"+i].innerHTML = "<input disabled type=checkbox id=rrr46_"+d2(i)+">";
			}
		} else {
			document.all["amount46_"+i].innerHTML = Math.floor(amount);
			document.all["chg46_"+i].innerHTML = "<input disabled type=checkbox id=rrr46_"+d2(i)+">";
		}
		win1 = Math.floor(win - a00[3]);
		document.all["win46_"+i].innerHTML = win1;
		document.all["win46_"+i].className = (win1 < 0 ? "lost" : "win");
	}
}

function show_rate47(str)
{
	var a0 = str.split(",");
	var win = a0[0];
	for (i=1; i<3; i++) {
		a00 = a0[i].split("@");
		rate = a00[0];
		count = a00[1]-0;
		amount = a00[2]-0;
		chktime = a00[4]-0;
		document.all["rate47_"+i].innerHTML = rate;
		mchk47[i] = Math.floor(amount);
		if (count > 0) {
			document.all["amount47_"+i].innerHTML = "<a href=op.php?op=agent&fp=betlist&dt1="+_open+"&dt2="+_open+"&bettype=47&numbers="+i+">"+Math.floor(amount)+"</a>";
			if (chktime == 0 && amount > 0) {
				document.all["chg47_"+i].innerHTML = "<input type=checkbox id=rrr47_"+d2(i)+" onclick=\"quickrrr(47, "+i+")\">";
			} else {
				document.all["chg47_"+i].innerHTML = "<input disabled type=checkbox id=rrr47_"+d2(i)+">";
			}
		} else {
			document.all["amount47_"+i].innerHTML = Math.floor(amount);
			document.all["chg47_"+i].innerHTML = "<input disabled type=checkbox id=rrr47_"+d2(i)+">";
		}
		win1 = Math.floor(win - a00[3]);
		document.all["win47_"+i].innerHTML = win1;
		document.all["win47_"+i].className = (win1 < 0 ? "lost" : "win");
	}
}

function show_titleAmu(str)
{
	var a0 = str.split(",");
	var i = 0;
	var l = a0.length;
	var amu = 0;
	var clr = '';
	var oObj = '';
	for (i=0; i<l; i++) {
		a00 = a0[i].split("@");
		amu = a00[0];
		if(a00[1] > 0){ clr = '#ffff99';  }else{ clr = 'transparent';  }
    oObj = document.getElementById("menuAmu"+i);
    oObj.innerHTML = amu;
    oObj.style.backgroundColor = clr;
	}
}

function quickrrr0(i)
{
	if (document.all["rrr0_"+d2(i)].checked) {
		if (timer_id) clearTimeout(timer_id);
		//timer_id = setTimeout("timer()", 90000);
	}
}

function quickrrr(c, i)
{
	if (document.all["rrr"+c+"_"+d2(i)].checked) {
		if (!chkbutmod) {
			chkbutmod = true;
		}
		if (timer_id) clearTimeout(timer_id);
		//timer_id = setTimeout("timer()", 90000);
	}
}

function gen_rate0()
{
	ret = "<table width=100% cellpadding=2 cellspacing=1 border=0 class=table0>"
		+"<tr id=rate0hd class=td0 align=center>";
	for (i=0; i<5; i++)
		ret += _tb0head;
	ret += "</tr>";
	
	for (j=1; j<=10; j++) {
		ret += "<tr class=td2 align=right>";
		for (i=0; i<5; i++) {
			k = i*10 + j;
			if (k > 49) {
				ret += "<td colspan=6>"+_total+"：<b id=amount0></b></td>";
			} else {
				ret += "<td id=num0_"+k+"></td><td nowrap id=amount0_"+k+"></td><td nowrap id=win0_"+k+"></td><td nowrap id=bo_"+k+"></td><td id=rate0_"+k+" class=rate></td><td id=chg0_"+k+" align=center></td>";
			}
		}
	}
	ret += "</table>";
	document.all.div0.innerHTML = ret;
}

function gen_rate1()
{
	ret = "<table width=100% cellpadding=2 cellspacing=1 border=0 class=table0>"
		+"<tr id=rate0hd class=td0 align=center>"+_tb1head+"</tr>";
	ret += "<tr class=td2 align=right><td class=td15 align=center>"+_name1[1]+"</td><td nowrap id=amount1_1></td><td nowrap id=win1_1></td><td id=rate1_1 class=rate></td><td id=chg1_1 align=center></td></tr>";
	ret += "<tr class=td2 align=right><td class=td15 align=center>"+_name1[2]+"</td><td nowrap id=amount1_2></td><td nowrap id=win1_2></td><td id=rate1_2 class=rate></td><td id=chg1_2 align=center></td></tr>";
	ret += "</table>";
	document.all.div1.innerHTML = ret;
}

function gen_rate2()
{
	ret = "<table width=100% cellpadding=2 cellspacing=1 border=0 class=table0>"
		+"<tr id=rate0hd class=td0 align=center>"+_tb1head+"</tr>";
	ret += "<tr class=td2 align=right><td class=td15 align=center>"+_name2[1]+"</td><td nowrap id=amount2_1></td><td nowrap id=win2_1></td><td id=rate2_1 class=rate></td><td id=chg2_1 align=center></td></tr>";
	ret += "<tr class=td2 align=right><td class=td15 align=center>"+_name2[2]+"</td><td nowrap id=amount2_2></td><td nowrap id=win2_2></td><td id=rate2_2 class=rate></td><td id=chg2_2 align=center></td></tr>";
	ret += "</table>";
	document.all.div2.innerHTML = ret;
}

function gen_rate2a()
{
	ret = "<table width=100% cellpadding=2 cellspacing=1 border=0 class=table0>"
		+"<tr id=rate0hd class=td0 align=center>"+_tb1head+"</tr>";
	ret += "<tr class=td2 align=right><td class=td15 align=center>"+_name2a[1]+"</td><td nowrap id=amount20_1></td><td nowrap id=win20_1></td><td id=rate20_1 class=rate></td><td id=chg20_1 align=center></td></tr>";
	ret += "<tr class=td2 align=right><td class=td15 align=center>"+_name2a[2]+"</td><td nowrap id=amount20_2></td><td nowrap id=win20_2></td><td id=rate20_2 class=rate></td><td id=chg20_2 align=center></td></tr>";
	ret += "</table>";
	document.all.div2a.innerHTML = ret;
}

function gen_rate3()
{
	ret = "<table width=100% cellpadding=2 cellspacing=1 border=0 class=table0>"
		+"<tr id=rate0hd class=td0 align=center>"+_tb1head+"</tr>";
	ret += "<tr class=td2 align=right><td class=td15 align=center>"+_name3[1]+"</td><td nowrap id=amount3_1></td><td nowrap id=win3_1></td><td id=rate3_1 class=rate></td><td id=chg3_1 align=center></td></tr>";
	ret += "<tr class=td2 align=right><td class=td15 align=center>"+_name3[2]+"</td><td nowrap id=amount3_2></td><td nowrap id=win3_2></td><td id=rate3_2 class=rate></td><td id=chg3_2 align=center></td></tr>";
	ret += "</table>";
	document.all.div3.innerHTML = ret;
}

function gen_rate28()
{
	ret = "<table width=100% cellpadding=2 cellspacing=1 border=0 class=table0>"
		+"<tr id=rate0hd class=td0 align=center>"+_tb1head+"</tr>";
	ret += "<tr class=td2 align=right><td class=td15 align=center>"+_name28[1]+"</td><td nowrap id=amount28_1></td><td nowrap id=win28_1></td><td id=rate28_1 class=rate></td><td id=chg28_1 align=center></td></tr>";
	ret += "<tr class=td2 align=right><td class=td15 align=center>"+_name28[2]+"</td><td nowrap id=amount28_2></td><td nowrap id=win28_2></td><td id=rate28_2 class=rate></td><td id=chg28_2 align=center></td></tr>";
	ret += "</table>";
	document.all.div28.innerHTML = ret;
}

function gen_rate30()
{
	ret = "<table width=100% cellpadding=2 cellspacing=1 border=0 class=table0>"
		+"<tr id=rate0hd class=td0 align=center>"+_tb1head+"</tr>";
	ret += "<tr class=td2 align=right><td class=td15 align=center>"+_name30[1]+"</td><td nowrap id=amount30_1></td><td nowrap id=win30_1></td><td id=rate30_1 class=rate></td><td id=chg30_1 align=center></td></tr>";
	ret += "<tr class=td2 align=right><td class=td15 align=center>"+_name30[2]+"</td><td nowrap id=amount30_2></td><td nowrap id=win30_2></td><td id=rate30_2 class=rate></td><td id=chg30_2 align=center></td></tr>";
	ret += "</table>";
	document.all.div30.innerHTML = ret;
}

function gen_rate46()
{
	ret = "<table width=100% cellpadding=2 cellspacing=1 border=0 class=table0>"
		+"<tr id=rate0hd class=td0 align=center>"+_tb146head+"</tr>";
	ret += "<tr class=td2 align=right><td class=td15 align=center>"+_name46[1]+"</td><td nowrap id=amount46_1></td><td nowrap id=win46_1></td><td id=rate46_1 class=rate></td><td align=center id=chg46_1></td></tr>";
	ret += "<tr class=td2 align=right><td class=td15 align=center>"+_name46[2]+"</td><td nowrap id=amount46_2></td><td nowrap id=win46_2></td><td id=rate46_2 class=rate></td><td align=center id=chg46_2></td></tr>";
	ret += "<tr class=td2 align=right><td class=td15 align=center>"+_name46[3]+"</td><td nowrap id=amount46_3></td><td nowrap id=win46_3></td><td id=rate46_3 class=rate></td><td align=center id=chg46_3></td></tr>";
	ret += "</table>";
	document.all.div46.innerHTML = ret;
}

function gen_rate47()
{
	ret = "<table width=100% cellpadding=2 cellspacing=1 border=0 class=table0>"
		+"<tr id=rate0hd class=td0 align=center>"+_tb1head+"</tr>";
	ret += "<tr class=td2 align=right><td class=td15 align=center>"+_name47[1]+"</td><td nowrap id=amount47_1></td><td nowrap id=win47_1></td><td id=rate47_1 class=rate></td><td id=chg47_1 align=center></td></tr>";
	ret += "<tr class=td2 align=right><td class=td15 align=center>"+_name47[2]+"</td><td nowrap id=amount47_2></td><td nowrap id=win47_2></td><td id=rate47_2 class=rate></td><td id=chg47_2 align=center></td></tr>";
	ret += "</table>";
	document.all.div47.innerHTML = ret;
}
function prot_chk_bo()
{
	var bw = 262;
	var sr = 0;
	var _btype = new Array();
	var _num = new Array();
	var _rate = new Array();
	var _chk = new Array();
	var _amount = new Array();
	var mm =0;
	var hi =104;
	var count = 0;
	if (document.all.amount0.innerHTML > 0) {
		for (i=0; i<49; i++) {
			ii = i+1;
			mm = document.all["bo_"+ii].innerHTML;
			if (document.all["rrr0_"+d2(ii)].checked && mm > 0) {
				_btype[count] = 0;
				_num[count] = document.all["num0_"+ii].innerHTML;
				_rate[count] = document.all["rate0_"+ii].innerHTML;
				_chk[count] = mchk0[ii];
				_amount[count] = mm;
				document.all["rrr0_"+d2(ii)].checked = false;
				count++;
			}
		}
		if (count > 0) {
			hi += (count * 26);
			if (count > 24) {
				sr = 1;
				bw = 280;
				hi = 794;
			}
			var X = screen.width - bw - 10;
			var Y = 0;
			//var newwin = window.open("op.php?op=agent&fp=protsaves&btype="+_btype+"&num="+_num+"&rate="+_rate+"&amount="+_amount+"&chk="+_chk,'WinProtPop','menubar=no,status=yes,scrollbars='+sr+',toolbar=no,top='+Y+',left='+X+',width='+bw+',height='+hi);
			//setTimeout("isPopOpen(newwin)",1500);
			var newwin = myCreateDiv("op.php?op=agent&fp=protsaves&btype="+_btype+"&num="+_num+"&rate="+_rate+"&amount="+_amount+"&chk="+_chk);
		}
	}
	timer();
}

function protect_bo()
{
	var bw = 262;
	var sr = 0;
	var _btype = new Array();
	var _num = new Array();
	var _rate = new Array();
	var _chk = new Array();
	var _amount = new Array();
	var mm =0;
	var hi =104;
	var count = 0;
	if (document.all.amount0.innerHTML > 0) {
		for (i=0; i<49; i++) {
			ii = i+1;
			if (document.all["rrr0_"+d2(ii)].checked) { document.all["rrr0_"+d2(ii)].checked = false; }  // true
			mm = document.all["bo_"+ii].innerHTML;
			if (mm > 0) {
				_btype[count] = 0;
				_num[count] = document.all["num0_"+ii].innerHTML;
				_rate[count] = document.all["rate0_"+ii].innerHTML;
				_chk[count] = mchk0[ii];
				_amount[count] = mm;
				count++;
			}
		}
		if (count > 0) {
			hi += (count * 26);
			if (count > 24) {
				sr = 1;
				bw = 280;
				hi = 794;
			}
			var X = screen.width - bw - 10;
			var Y = 0;
			//var newwin = window.open("op.php?op=agent&fp=protsaves&btype="+_btype+"&num="+_num+"&rate="+_rate+"&amount="+_amount+"&chk="+_chk,'WinProtPop','menubar=no,status=yes,scrollbars='+sr+',toolbar=no,top='+Y+',left='+X+',width='+bw+',height='+hi);
			var newwin = myCreateDiv("op.php?op=agent&fp=protsaves&btype="+_btype+"&num="+_num+"&rate="+_rate+"&amount="+_amount+"&chk="+_chk);
			//setTimeout("isPopOpen(newwin)",1500);
		}
	}
}

function protect_b1()
{
	var bw = 262;
	var sr = 0;
	var hi =104;
	var cc = "";
	var count = 0;
	var _bet = new Array();
	var _num = new Array();
	var _chk = new Array();
	var _rate = new Array();
	var _amount = new Array();
	b13_num = document.all.b13.value-0;
	if (b13_num > 0) {
		for (i=1; i<3; i++) {
			if (document.all["rrr1_"+d2(i)].checked) {
				_bet[count] = 1;
				_num[count] = i;
				_rate[count] = document.all["rate1_"+i].innerHTML;
				_chk[count] = mchk1[i];
				_amount[count] = b13_num;
				count++;
			}
			if (document.all["rrr2_"+d2(i)].checked) {
				_bet[count] = 2;
				_num[count] = i;
				_rate[count] = document.all["rate2_"+i].innerHTML;
				_chk[count] = mchk2[i];
				_amount[count] = b13_num;
				count++;
			}
			if (document.all["rrr3_"+d2(i)].checked) {
				_bet[count] = 3;
				_num[count] = i;
				_rate[count] = document.all["rate3_"+i].innerHTML;
				_chk[count] = mchk3[i];
				_amount[count] = b13_num;
				count++;
			}
			if (document.all["rrr20_"+d2(i)].checked) {
				_bet[count] = 20;
				_num[count] = i;
				_rate[count] = document.all["rate20_"+i].innerHTML;
				_chk[count] = mchk20[i];
				_amount[count] = b13_num;
				count++;
			}
			if (document.all["rrr28_"+d2(i)].checked) {
				_bet[count] = 28;
				_num[count] = i;
				_rate[count] = document.all["rate28_"+i].innerHTML;
				_chk[count] = mchk28[i];
				_amount[count] = b13_num;
				count++;
			}
			if (document.all["rrr30_"+d2(i)].checked) {
				_bet[count] = 30;
				_num[count] = i;
				_rate[count] = document.all["rate30_"+i].innerHTML;
				_chk[count] = mchk30[i];
				_amount[count] = b13_num;
				count++;
			}
			if (document.all["rrr47_"+d2(i)].checked) {
				_bet[count] = 47;
				_num[count] = i;
				_rate[count] = document.all["rate47_"+i].innerHTML;
				_chk[count] = mchk47[i];
				_amount[count] = b13_num;
				count++;
			}
		}
		for (i=1; i<4; i++) {
			if (document.all["rrr46_"+d2(i)].checked) {
				_bet[count] = 46;
				_num[count] = i;
				_rate[count] = document.all["rate46_"+i].innerHTML;
				_chk[count] = mchk46[i];
				_amount[count] = b13_num;
				count++;
			}
		}
		if (count > 0) {
			hi += (count * 26);
			if (count > 24) {
				sr = 1;
				bw = 280;
				hi = 794;
			}
			var X = screen.width - bw - 10;
			var Y = 0;
			//var newwin = window.open("op.php?op=agent&fp=protsaves&btype="+_bet+"&num="+_num+"&rate="+_rate+"&amount="+_amount+"&chk="+_chk,'WinProtPop','menubar=no,status=yes,scrollbars='+sr+',toolbar=no,top='+Y+',left='+X+',width='+bw+',height='+hi);
			//setTimeout("isPopOpen(newwin)",1500);
			var newwin = myCreateDiv("op.php?op=agent&fp=protsaves&btype="+_bet+"&num="+_num+"&rate="+_rate+"&amount="+_amount+"&chk="+_chk);
		}
	}
	b13_num = "";
	document.all.b13.value = b13_num;
	if (chkbutmod) {
		chkbutmod = false;
		timer();
	}
}

function prot_list()
{
	var X = (screen.width-470)/2;
	var Y = (screen.Height-424)/2;
	//var newwin = window.open("op.php?op=agent&fp=protlists&bmd=0",'WinPopList','menubar=no,status=yes,scrollbars=no,toolbar=no,top='+Y+',left='+X+',width=540,height=412');
	var newwin = myCreateDiv("op.php?op=agent&fp=protlists&bmd=0");
	//setTimeout("isPopOpen(newwin)",1500);
}

function isPopOpen(obj)
{
	if (obj == null) alert("注意，快显视窗被阻挡，请检查IE浏览器的设定！");
}

function myCreateDiv(sSrc){
    var shadow = document.createElement("div");
    shadow.setAttribute("id","speShadow2");
    shadow.style.zIndex="100";

    var box = document.createElement("div");
    box.setAttribute("id","speBox2");
    box.style.zIndex="999";
    
    var closeBar = document.createElement("div");
    closeBar.setAttribute("id","closeBar");
    
    var iptClose = document.createElement("input");
    iptClose.setAttribute("type","button");
    iptClose.setAttribute("value"," X ");
    iptClose.setAttribute("className","c4");
    iptClose.onclick = function() {myCloseMyDiv(0);};
    
    closeBar.appendChild(iptClose);
    box.appendChild(closeBar);
    
    var myIframe = document.createElement("iframe");
    myIframe.setAttribute("id","myIfram_target");
    myIframe.setAttribute("name","myIfram_target");
    myIframe.style.width = "100%";
    myIframe.style.height = "100%";
    myIframe.src = sSrc;
    box.appendChild(myIframe);
    
    document.body.appendChild(shadow);
    document.body.appendChild(box);    
}

function myCloseMyDiv(oReload){
    var shadow=document.getElementById("speShadow2");
    if(shadow != undefined){
      var box=document.getElementById("speBox2");
      document.body.removeChild(box);
      document.body.removeChild(shadow);
      if(oReload) window.location.reload();
    }
    
}


function w(s) {
	document.write(s);
}

function winonload()
{
	gen_rate0();
	gen_rate1();
	gen_rate2();
	gen_rate3();
	gen_rate28();
	gen_rate30();
	gen_rate2a();
	gen_rate46();
	gen_rate47();
	bo0_num = document.all.bo0.value-0;
	if (bo0_num > 0) { bo0_num = 0-bo0_num; }
	b13_num = document.all.b13.value-0;
	chkbutmod = false;

	timer();
}

window.onload = winonload;